﻿using System;
using System.Data.SqlClient;
using System.Data;
using Microsoft.ApplicationBlocks.Data;

/// <summary>
/// SubsidyRecord 的摘要说明
/// </summary>
namespace Housing
{
    [Serializable]
    public class SubsidyRecord
    {
        private int _adjid;
        private string _longid;
        private string _checked;
        private string _nowmoney;
        private string _moneychange;
        private string _nowarea;
        private string _iscontinue;
        private string _starttime;
        private string _stoptime;
        private string _remark;
        private string _date;
        private string _noid;
        private string _reason;


        private int _effectDate;
        public int EffectDate
        {
            get { return _effectDate; }
            set { _effectDate = value; }
        }
        private int _applyid;
        public int Applyid
        {
            get { return _applyid; }
            set { _applyid = value; }
        }


        public SubsidyRecord(int adjId)
        {
            GetSubsidyRecordById(adjId);
        }

        public SubsidyRecord()
        {
        }
        public int Adj_id
        {
            get { return _adjid; }
            set { _adjid = value; }
        }

        public string Adj_longid
        {
            get { return _longid; }
            set { _longid = value; }
        }

        public string Adj_checked
        {
            get { return _checked; }
            set { _checked = value; }
        }

        public string Adj_nowarea
        {
            get { return _nowarea; }
            set { _nowarea = value; }
        }

        public string Adj_moneychange
        {
            get { return _moneychange; }
            set { _moneychange = value; }
        }

        public string Adj_nowmoney
        {
            get { return _nowmoney; }
            set { _nowmoney = value; }
        }

        public string Adj_iscontinue
        {
            get { return _iscontinue; }
            set { _iscontinue = value; }
        }

        public string Adj_starttime
        {
            get { return _starttime; }
            set { _starttime = value; }
        }

        public string Adj_stoptime
        {
            get { return _stoptime; }
            set { _stoptime = value; }
        }

        public string Adj_remark
        {
            get { return _remark; }
            set { _remark = value; }
        }

        public string Adj_date
        {
            get { return _date; }
            set { _date = value; }
        }

        public string Adj_noid
        {
            get { return _noid; }
            set { _noid = value; }
        }

        public string Adj_reason 
        {
            get { return _reason; }
            set { _reason = value; }
        }

        protected string connString = SqlHelper.ConnectionString;

        public static string getAdj_moneychange(string applyid, string effectDate,string nowmoney)
        {
            string moneychange = "";
            SqlParameter[] param = new SqlParameter[4];
            param[0] = new SqlParameter("@applyid", applyid);
            param[1] = new SqlParameter("@EffectDate", effectDate);
            param[2] = new SqlParameter("@nowmoney", nowmoney);
            param[3] = new SqlParameter("@moneychange",SqlDbType.VarChar,100);
            param[3].Direction = ParameterDirection.Output;
            SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.StoredProcedure, "getSubsidyMoneychange",param);
            moneychange = param[3].Value.ToString();
            return moneychange;

        }

        //方法
        public void GetSubsidyRecordById(int adjid)
        {
            string query = "SELECT * FROM SubsidyRecord WHERE adj_id=" + adjid;
            SqlDataReader reader = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (reader.Read())
            {
                Adj_id = (int)reader[0];
                Adj_longid = reader[1].ToString();
                Adj_checked = reader[2].ToString();
                Adj_nowmoney = Utils.GetString(reader[3]);
                Adj_moneychange = Utils.GetString(reader[4]);
                Adj_nowarea = Utils.GetString(reader[5]);
                Adj_iscontinue = reader[6].ToString();
                Adj_starttime = Utils.GetString(reader[7]);
                Adj_stoptime = Utils.GetString(reader[8]);
                Adj_remark = Utils.GetString(reader[9]);
                Adj_date = Utils.GetString(reader[10]);
                Adj_noid = Utils.GetString(reader[11]);
                Adj_reason = Utils.GetString(reader[12]);
            }
            reader.Close();
        }

        public bool AddNewSubsidyRecord(SubsidyRecord subsidyrecord)
        {
            string query = @"INSERT INTO SubsidyRecord(adj_longid, adj_checked, adj_nowmoney, adj_moneychange,adj_nowarea,adj_iscontinue,adj_starttime,adj_stoptime,adj_remark,adj_date,adj_noid,adj_reason,applyid,EffectDate) 
                            VALUES('" + subsidyrecord._longid + "','" + subsidyrecord._checked + "','" + subsidyrecord._nowmoney + "','" + subsidyrecord._moneychange + "','" + subsidyrecord._nowarea + "',";
            query += "'" + subsidyrecord._iscontinue + "','" + subsidyrecord._starttime + "','" + subsidyrecord._stoptime + "','" + subsidyrecord._remark + "','" + subsidyrecord._date + "','" + subsidyrecord._noid + "','" + subsidyrecord._reason + "'," + subsidyrecord.Applyid + "," + subsidyrecord.EffectDate + ")";
            bool result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, query));
            return result;
        }

        public bool UpdateASubsidyRecord(SubsidyRecord subsidyrecord)
        {
            string query = @"UPDATE SubsidyRecord SET adj_longid='" + subsidyrecord._longid + "', adj_checked='" + subsidyrecord._checked + "', adj_nowmoney='" + subsidyrecord._nowmoney + "',adj_nowarea='" + subsidyrecord._nowarea + "',";
            query += "adj_moneychange='" + subsidyrecord._moneychange + "',adj_iscontinue='" + subsidyrecord._iscontinue + "',adj_starttime='"+subsidyrecord._starttime+"',adj_stoptime='" + subsidyrecord._stoptime + "',adj_remark=";
            query+="'" + subsidyrecord._remark + "',adj_date='" + subsidyrecord._date + "',adj_noid='"+subsidyrecord._noid+"',adj_reason='"+subsidyrecord._reason+"' WHERE adj_id=" + subsidyrecord._adjid;
            bool result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, query));
            return result;
        }

        public bool UpdateASubsidyRecordByNoid(SubsidyRecord subsidyrecord)
        {

            string query = @"UPDATE SubsidyRecord SET adj_longid='" + subsidyrecord._longid + "', adj_checked='" + subsidyrecord._checked + "', adj_nowmoney='" + subsidyrecord._nowmoney + "',adj_nowarea='" + subsidyrecord._nowarea + "',";
            query += "adj_moneychange='" + subsidyrecord._moneychange + "',adj_iscontinue='" + subsidyrecord._iscontinue + "',adj_starttime='" + subsidyrecord._starttime + "',adj_stoptime='" + subsidyrecord._stoptime + "',adj_remark=";
            query += "'" + subsidyrecord._remark + "',adj_date='" + subsidyrecord._date + "',adj_noid='" + subsidyrecord._noid + "',adj_reason='" + subsidyrecord._reason + "' WHERE [adj_noid]=" + subsidyrecord._noid + " and  [adj_id]=(select top 1 adj_id from [SubsidyRecord] where [adj_noid]=" + subsidyrecord._noid + " order by adj_id desc)";
            bool result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, query));
            return result;
        }

        public bool DeleteASubsidyRecord(int adjid)
        {
            string query = "DELETE FROM SubsidyRecord WHERE adj_id=" + adjid;
            bool result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, query));
            return result;
        }

        public static bool DeleteASubsidyRecordByApplyid(int applyid)
        {
            string query = "DELETE FROM SubsidyRecord WHERE applyid=" + applyid.ToString();
            bool result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, query));
            return result;
        }

        /// <summary>
        /// 查看最新Subsidy记录
        /// </summary>
        /// <param name="noid"></param>
        public void GetNewestSubsidyRecordByNoid(string noid)
        {
            string query = "SELECT TOP 1 * FROM SubsidyRecord WHERE adj_noid=" + noid+" AND adj_checked=1 ORDER BY adj_id DESC";
            SqlDataReader reader = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (reader.Read())
            {
                Adj_id = (int)reader[0];
                Adj_longid = reader[1].ToString();
                Adj_checked = reader[2].ToString();
                Adj_nowmoney = Utils.GetString(reader[3]);
                Adj_moneychange = Utils.GetString(reader[4]);
                Adj_nowarea = Utils.GetString(reader[5]);
                Adj_iscontinue = reader[6].ToString();
                Adj_starttime = Utils.GetString(reader[7]);
                Adj_stoptime = Utils.GetString(reader[8]);
                Adj_remark = Utils.GetString(reader[9]);
                Adj_date = Utils.GetString(reader[10]);
                Adj_noid = Utils.GetString(reader[11]);
                Adj_reason = Utils.GetString(reader[12]);
            }
            reader.Close();
        }

        /// <summary>
        /// 查看最新Subsidy记录
        /// </summary>
        /// <param name="noid"></param>
        public void GetNewestSubsidyRecordByApplyID(string applyid)
        {
            string query = "SELECT TOP 1 * FROM SubsidyRecord WHERE applyid=" + applyid + " ORDER BY adj_id DESC";
            SqlDataReader reader = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (reader.Read())
            {
                Adj_id = (int)reader[0];
                Adj_longid = reader[1].ToString();
                Adj_checked = reader[2].ToString();
                Adj_nowmoney = Utils.GetString(reader[3]);
                Adj_moneychange = Utils.GetString(reader[4]);
                Adj_nowarea = Utils.GetString(reader[5]);
                Adj_iscontinue = reader[6].ToString();
                Adj_starttime = Utils.GetString(reader[7]);
                Adj_stoptime = Utils.GetString(reader[8]);
                Adj_remark = Utils.GetString(reader[9]);
                Adj_date = Utils.GetString(reader[10]);
                Adj_noid = Utils.GetString(reader[11]);
                Adj_reason = Utils.GetString(reader[12]);
            }
            reader.Close();
        }


        public void GetIfContinueThisMonth(string longid)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            string query = "SELECT TOP 1 * FROM SubsidyRecord WHERE adj_longid='" + longid + "' AND adj_iscontinue=1 AND adj_date=" + time + " ORDER BY adj_id DESC";
            SqlDataReader reader = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (reader.Read())
            {
                Adj_id = (int)reader[0];
                Adj_longid = reader[1].ToString();
                Adj_checked = reader[2].ToString();
                Adj_nowmoney = Utils.GetString(reader[3]);
                Adj_moneychange = Utils.GetString(reader[4]);
                Adj_nowarea = Utils.GetString(reader[5]);
                Adj_iscontinue = reader[6].ToString();
                Adj_starttime = Utils.GetString(reader[7]);
                Adj_stoptime = Utils.GetString(reader[8]);
                Adj_remark = Utils.GetString(reader[9]);
                Adj_date = Utils.GetString(reader[10]);
                Adj_noid = Utils.GetString(reader[11]);
                Adj_reason = Utils.GetString(reader[12]);
            }
            reader.Close();
        }

        public void GetIfChangedThisMonth(string longid)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            string query = "SELECT TOP 1 * FROM SubsidyRecord WHERE adj_longid='" + longid + "' AND adj_iscontinue=0 AND adj_date=" + time + " ORDER BY adj_id DESC";
            SqlDataReader dr = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (dr.Read())
            {
                Adj_id = (int)dr[0];
                Adj_longid = dr[1].ToString();
                Adj_checked = dr[2].ToString();
                Adj_nowmoney = Utils.GetString(dr[3]);
                Adj_moneychange = Utils.GetString(dr[4]);
                Adj_nowarea = Utils.GetString(dr[5]);
                Adj_iscontinue = Utils.GetString(dr[6]);
                Adj_starttime = Utils.GetString(dr[7]);
                Adj_stoptime = Utils.GetString(dr[8]);
                Adj_remark = Utils.GetString(dr[9]);
                Adj_date = Utils.GetString(dr[10]);
                Adj_noid = Utils.GetString(dr[11]);
                Adj_reason = Utils.GetString(dr[12]);
            }
            dr.Close();
        }

        /// 租金补贴(增加、减少)(申请)
        public bool ChangeSubsidyOprate(string longid, string noid, string nowmoney, string moneychange, string nowarea,
                                    string remark, string oldstoptime, string reason)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            DateTime dt = DateTime.Now.AddMonths(1);
            int starttime = dt.Year * 100 + dt.Month;
            SubsidyRecord subsidy = new SubsidyRecord();
            subsidy.GetIfChangedThisMonth(longid);
            string oldmoney = subsidy.Adj_nowmoney;
            if (subsidy.Adj_iscontinue == "0")
            {
                if (subsidy.Adj_checked == "1")
                {
                    subsidy.Adj_checked = "0";
                    subsidy.Adj_date = time.ToString();
                    subsidy.Adj_iscontinue = "0";
                    subsidy.Adj_longid = longid;
                    subsidy.Adj_noid = noid;
                    subsidy.Adj_nowarea = nowarea;
                    subsidy.Adj_nowmoney = nowmoney;
                    subsidy.Adj_moneychange = (float.Parse(nowmoney) - float.Parse(oldmoney)).ToString();
                    subsidy.Adj_remark = remark;
                    subsidy.Adj_starttime = starttime.ToString();
                    subsidy.Adj_stoptime = oldstoptime;
                    subsidy.Adj_reason = reason;
                    subsidy.AddNewSubsidyRecord(subsidy);
                }
                else
                {
                    subsidy.Adj_nowarea = nowarea;
                    subsidy.Adj_nowmoney = nowmoney;
                    subsidy.Adj_moneychange = (float.Parse(nowmoney) - float.Parse(oldmoney)).ToString();
                    subsidy.Adj_remark = remark;
                    subsidy.Adj_date = time.ToString();
                    subsidy.Adj_reason = reason;
                    subsidy.UpdateASubsidyRecord(subsidy);
                }
            }
            else
            {
                subsidy.Adj_checked = "0";
                subsidy.Adj_date = time.ToString();
                subsidy.Adj_iscontinue = "0";
                subsidy.Adj_longid = longid;
                subsidy.Adj_noid = noid;
                subsidy.Adj_nowarea = nowarea;
                subsidy.Adj_nowmoney = nowmoney;
                subsidy.Adj_moneychange = (float.Parse(nowmoney) - float.Parse(oldmoney)).ToString();
                subsidy.Adj_remark = remark;
                subsidy.Adj_starttime = starttime.ToString(); ;
                subsidy.Adj_stoptime = oldstoptime;
                subsidy.Adj_reason = reason;
                subsidy.AddNewSubsidyRecord(subsidy);
            }
            return true;
        }

        /// 获取租金补贴调整信息
        public DataSet GetSubsidyChanges(string street)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            string query = "";
            if (street == "海曙")
                query = @"SELECT A.apply_name,A.apply_address,A.apply_time,S.adj_id,A.apply_longid,A.apply_noid FROM Apply AS A INNER JOIN SubsidyRecord AS S ON "
                  + "A.apply_longid=S.adj_longid WHERE S.adj_checked=0 AND S.adj_iscontinue=0 AND S.adj_date=" + time + "  AND A.apply_id "
                  + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid ORDER BY apply_id DESC)";
            else
                query = @"SELECT A.apply_name,A.apply_address,A.apply_time,S.adj_id,A.apply_longid,A.apply_noid FROM Apply AS A INNER JOIN KindRecord AS S ON "
                  + "A.apply_longid=S.adj_longid WHERE S.adj_checked=0 AND S.adj_iscontinue=0 AND S.adj_date=" + time + " AND A.apply_id "
                  + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid AND apply_street='" + street + "' ORDER BY apply_id DESC)";
            DataSet ds = SqlHelper.ExecuteDataset(connString, CommandType.Text, query);
            return ds;
        }

        /// 通过---租金补贴调整申请
        public bool SetSubsidyChangePass(string longid, int adjid)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            SubsidyRecord subsidy = new SubsidyRecord(adjid);
            //判断本月是否有已审核通过的历史记录
            string query = "SELECT TOP 1 adj_id FROM SubsidyRecord WHERE adj_checked=1 AND adj_longid='" + longid + "' AND adj_date=" + time + " ORDER BY adj_id DESC";
            int ID = SqlHelper.ExecuteNonQuery(connString, CommandType.Text, query);
            if (ID > 0)
            {
                //本月有记录则删除原记录，标记新纪录为通过
                SqlConnection conn = new SqlConnection(connString);
                conn.Open();
                SqlTransaction transaction = conn.BeginTransaction();
                try
                {
                    query = "DELETE FROM SubsidyRecord WHERE adj_id=" + ID;
                    SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, query, null);
                    string cmdtext = "UPDATE SubsidyRecord SET adj_checked=1 WHERE adj_id=" + adjid;
                    SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, cmdtext, null);
                    transaction.Commit();
                    return true;
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return false;
                }
            }
            else
            {
                //本月没有记录则标记新纪录为通过
                subsidy.GetSubsidyRecordById(adjid);
                subsidy.Adj_checked = "1";
                return subsidy.UpdateASubsidyRecord(subsidy);
            }
        }

        /// 否决---租金补贴调整申请
        public bool SetSubsidyChangeUnPass(int adjid)
        {
            SubsidyRecord subsidy = new SubsidyRecord();
            return subsidy.DeleteASubsidyRecord(adjid);
        }

        ///租金补贴续办(申请)
        public bool ContinueSubsidyOprate(string longid,string noid, string stoptime, string remark,string reason)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            DateTime dt = DateTime.Now.AddMonths(1);
            int starttime = dt.Year * 100 + dt.Month;
            SubsidyRecord subsidy = new SubsidyRecord();
            subsidy.GetIfContinueThisMonth(longid);
            if (subsidy.Adj_iscontinue == "1")
            {
                if (subsidy.Adj_checked == "1")
                {
                    subsidy.Adj_checked = "0";
                    subsidy.Adj_date = time.ToString();
                    subsidy.Adj_iscontinue = "1";
                    //subsidy.Adj_longid = longid;
                    //subsidy.Adj_moneychange = "";
                    //subsidy.Adj_noid = noid;
                    //subsidy.Adj_nowarea = "";
                    //subsidy.Adj_nowmoney = "";
                    subsidy.Adj_remark = remark;
                    subsidy.Adj_starttime = starttime.ToString();
                    subsidy.Adj_stoptime = stoptime;
                    subsidy.Adj_reason = reason;
                    subsidy.AddNewSubsidyRecord(subsidy);
                }
                else
                {
                    subsidy.Adj_remark = remark;
                    subsidy.Adj_reason = reason;
                    subsidy.Adj_starttime = starttime.ToString();
                    subsidy.Adj_stoptime = stoptime;
                    subsidy.UpdateASubsidyRecord(subsidy);
                }
                return true;
            }
            else
            {//若本月还没有续办申请，读取该用户最新实物配租信息并添加新纪录
                string query = "SELECT TOP 1 * FROM SubsidyRecord WHERE adj_longid='" + longid + "' AND adj_checked=1";
                SqlDataReader dr = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
                if (dr.Read())
                {
                    subsidy.Adj_checked = "0";//
                    subsidy.Adj_date = time.ToString();//
                    subsidy.Adj_iscontinue = "1";//
                    subsidy.Adj_longid = longid;//
                    subsidy.Adj_moneychange = dr["adj_moneychange"].ToString();//
                    subsidy.Adj_noid = noid;//
                    subsidy.Adj_nowarea = dr["adj_nowarea"].ToString();//
                    subsidy.Adj_nowmoney = dr["adj_nowmoney"].ToString();//
                    subsidy.Adj_remark = remark;//
                    subsidy.Adj_starttime = starttime.ToString();//
                    subsidy.Adj_stoptime = stoptime;//
                    subsidy.Adj_reason = reason;//
                    subsidy.AddNewSubsidyRecord(subsidy);
                }
            }
            return true;
        }
        
        ///获取租金补贴续办信息
        public DataSet GetSubsidyContinues(string street)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            string query = "";
            if(street=="海曙")
                query = @"SELECT A.apply_name,A.apply_address,A.apply_time,S.adj_id,A.apply_longid,S.adj_stoptime,S.adj_reason FROM Apply AS A "
                    + "INNER JOIN SubsidyRecord AS S ON A.apply_longid=S.adj_longid WHERE S.adj_checked=0 AND S.adj_iscontinue=1 AND S.adj_date=" + time + " AND A.apply_id "
                    +"IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid ORDER BY apply_id DESC)";
            else
                query = @"SELECT A.apply_name,A.apply_address,A.apply_time,S.adj_id,A.apply_longid,S.adj_stoptime,S.adj_reason FROM Apply AS A "
                    + "INNER JOIN SubsidyRecord AS S ON A.apply_longid=S.adj_longid WHERE S.adj_checked=0 AND S.adj_iscontinue=1 AND S.adj_date=" + time + " AND A.apply_id "
                    + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid AND apply_street='"+street+"' ORDER BY apply_id DESC)";
            DataSet ds = SqlHelper.ExecuteDataset(connString,CommandType.Text,query);
            return ds;
        }

        /// 通过----租金补贴续办申请
        public bool SetSubsidyContinuePass(string longid, int adjid)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            DateTime dt = DateTime.Now.AddMonths(1);
            int nextmonth = dt.Year * 100 + dt.Month;
            SubsidyRecord subsidy = new SubsidyRecord(adjid);
            //判断本月是否有已审核通过的历史记录
            string query = "SELECT TOP 1 adj_id FROM SubsidyRecord WHERE adj_checked=1 AND adj_longid='" + longid + "' AND adj_date=" + time + " ORDER BY adj_id DESC";
            int ID = SqlHelper.ExecuteNonQuery(connString, CommandType.Text, query);
            if (ID>0)
            {
                //本月有记录则删除旧记录，更新新纪录
                SqlConnection conn = new SqlConnection(connString);
                conn.Open();
                SqlTransaction transaction = conn.BeginTransaction();
                try
                {
                    query = "DELETE FROM SubsidyRecord WHERE adj_id=" + ID;
                    SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, query, null);
                    string cmdtext = "UPDATE SubsidyRecord SET adj_checked=1 WHERE adj_id=" + adjid;
                    SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, cmdtext, null);
                    transaction.Commit();
                    return true;
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return false;
                }
            }
            else
            {
                //本月没有记录则插入新纪录
                subsidy.GetSubsidyRecordById(adjid);
                subsidy.Adj_checked = "1";
                return subsidy.UpdateASubsidyRecord(subsidy);
            }
        }

        /// 否决----租金补贴续办申请
        public bool SetSubsidyContinueUnPass(int adjid)
        {
            SubsidyRecord subsidy = new SubsidyRecord();
            return subsidy.DeleteASubsidyRecord(adjid);
        }
        //public DataSet GetSubsidyChanges(string street)
        //{
        //    int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
        //    string query = "";
        //    if (street == "海曙")
        //        query = @"A.apply_name,A.apply_address,A.apply_time FROM Apply AS A INNER JOIN SubsidyRecord AS S ON A.apply_longid=S.adj_longid "
        //            + "WHERE S.adj_checked=0 AND S.adj_iscontinue=0 AND S.adj_date=" + time + " AND A.apply_id "
        //            + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid ORDER BY apply_id DESC)";
        //    else
        //        query = @"A.apply_name,A.apply_address,A.apply_time FROM Apply AS A INNER JOIN SubsidyRecord AS S ON A.apply_longid=S.adj_longid "
        //            + "WHERE S.adj_checked=0 AND S.adj_iscontinue=0 AND S.adj_date=" + time + " AND A.apply_id "
        //            + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid AND apply_street='" + street + "' ORDER BY apply_id DESC)";
        //    DataSet ds = SqlHelper.ExecuteDataset(connString, CommandType.Text, query);
        //    return ds;
        //}

    }
}
